MiniMessage = function( container ) {
	
	this.messages = $( "<ul/>" );
	this.messages.addClass( "miniMessage" );
	
	this.container = container != null ? container : $( document.body );
	this.container.append( this.messages );
};

MiniMessage.prototype.container = null;
MiniMessage.prototype.messages = null;
	
MiniMessage.prototype.dismissMessage = function( message ) {
	
	try {
		$( message ).remove();
	}
	catch( Error ) {
		// ignore
	}
};

MiniMessage.prototype.createMessage = function( message ) {
	
	var messageElement = $( "<li>"+ message.toString() +"</li>" );
	messageElement.addClass( "miniMessageItem" );
	this.messages.append( messageElement );
	return messageElement;
};

MiniMessage.prototype.createStaticMessage = function( message ) {
	
	return this.createMessage( message );
};

MiniMessage.prototype.createTimerMessage = function( message, seconds, callback ) {
	
	var messageElement = this.createMessage( message );
	
	var me = this;
	var dismissMessageFn = function() { 
			me.dismissMessage( messageElement );
			callback.call( me, messageElement );
		};
	window.setTimeout( dismissMessageFn, seconds * 1000 )
	
	return messageElement
};

MiniMessage.prototype.createDismissableMessage = function( message ) {
	
	var message = this.createMessage( message );
	message.click( this.messageClickHandler.bind( this ) );
};

MiniMessage.prototype.messageClickHandler = function( event ) {
	this.dismissMessage( event.target )
};